// cc.GhostEffect.WebGLRenderCmd = function (renderableObject) {
//     this._rootCtor(renderableObject);
//     this._needDraw = true;

//     this._fBO = null;
//     this._oldFBO = null;
//     this._textureCopy = null;
//     this._depthRenderBuffer = null;

//     this._rtTextureRect = new cc.Rect();
//     this._fullRect = new cc.Rect();
//     this._fullViewport = new cc.Rect();
// };

// var proto = cc.GhostEffect.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype);
// proto.constructor = cc.GhostEffect.WebGLRenderCmd;

// proto.rendering = function (ctx)
// {
//     var gl = ctx || cc._renderContext;
//     var node = this._node;
//     node.begin();

//     node.sortAllChildren();
//     for (var i = 0; i < locChildren.length; i++) 
//     {
//         var getChild = locChildren[i];
//         if (getChild !== node.sprite) {
//             getChild.visit(node.sprite);    //TODO it's very Strange
//         }
//     }
//     node.end();
// }

// proto.initWithWidthAndHeight = function (width, height, format, depthStencilFormat) {
//     var node = this._node;
//     var gl = cc._renderContext;

//     var locTexture = null;

//     var oldRBO = gl.getParameter(gl.RENDERBUFFER_BINDING);



//     this._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING);

//     this._fBO = gl.createFramebuffer();
//     gl.bindFramebuffer(gl.FRAMEBUFFER, this._fBO);

//     //把Texture绑定至当前的FrameBuffer
//     gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, locTexture._glID, 0);

//     // gl.bindRenderbuffer(gl.RENDERBUFFER, oldRBO);
//     gl.bindFramebuffer(gl.FRAMEBUFFER, this._oldFBO);

//     return true;
// };

// proto.begin = function()
// {
//     var node = this._node; 
//     //保存当前矩阵
//     cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION);
//     cc.math.glPushMatrix();
//     cc.math.glMatrixMode(cc.math.KM_GL_MODELVIEW);
//     cc.math.glPushMatrix();
//     var gl = cc._renderContext;

//     var director = cc.director;
//     director.setProjection(director.getProjection());

//     // Calculate the adjustment ratios based on the old and new projections
//     var size = cc.director.getWinSizeInPixels();
//     var widthRatio = size.width / node._texture.width;
//     var heightRatio = size.height / node._texture.height;


//     var orthoMatrix = cc.math.Matrix4.createOrthographicProjection(-1.0 / widthRatio, 1.0 / widthRatio,
//         -1.0 / heightRatio, 1.0 / heightRatio, -1, 1);
//     cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION);
//     cc.math.glMultMatrix(orthoMatrix);


//     var viewport = new cc.Rect(0, 0, 0, 0);
//     viewport.width = this._fullViewport.width;
//     viewport.height = this._fullViewport.height;
//     var viewPortRectWidthRatio = viewport.width / this._fullRect.width;
//     var viewPortRectHeightRatio = viewport.height / this._fullRect.height;
//     viewport.x = (this._fullRect.x - this._rtTextureRect.x) * viewPortRectWidthRatio;
//     viewport.y = (this._fullRect.y - this._rtTextureRect.y) * viewPortRectHeightRatio;
//     gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);

//     this._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING);
//     if(null === this._fBO)
//     {
//         this._fBO = gl.createFramebuffer();
//     }
//     gl.bindFramebuffer(gl.FRAMEBUFFER, this._fBO);


// }


// proto.end = function()
// {
//     var node = this._node;
//     cc.renderer._renderingToBuffer(node.__instanceId);

//     var gl = cc._renderContext;
//     var director = cc.director;
//     gl.bindFramebuffer(gl.FRAMEBUFFER, this._oldFBO);

//     //restore viewport
//     director.setViewport();
//     cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION);
//     cc.math.glPopMatrix();
//     cc.math.glMatrixMode(cc.math.KM_GL_MODELVIEW);
//     cc.math.glPopMatrix();
// }